// pages/Manager/dkAbnormalList/dkAbnormalList.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        show:false,
        columns: ['待处理', '已处理', '全部'],
        columnStatus:['待处理','已处理'],
        activeNames:[],
        showStatus:false,
        id:'',
        showError:'',
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var _that=this
        wx.request({
          url: 'http://localhost/Wx/HtNowList?status=0',
          method:'get',
          success(res){
              console.log(res.data)
              if(res.data.code==200){
                _that.setData({
                    data:res.data.data,
                    showError:false
                })
              }else{
                _that.setData({
                  showError:true
                })
              }
          }

        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    BtnPop() {
        this.setData({ show: true });
      },
    onCancel(){
        this.setData({ show:false});
   },
   onConfirm(event) {
    var _that=this
    const { picker, value, index } = event.detail;
    console.log("value:"+value+",index:"+index)
    if(index==0){
      _that.setData({
        data:''
      })
      wx.request({
        url: 'http://localhost/Wx/HtNowList?status=0',
        success(res){
          console.log(res.data)
          if(res.data.code=200){
            _that.setData({
              data:res.data.data,
              showError:false,
              show:false
            })
          }else{
            _that.setData({
              showError:false
            })
          }

          
        }
      })
    }
    if(index==1){
      _that.setData({
        data:''
      })
      wx.request({
        url: 'http://localhost/Wx/HtNowList?status=1',
        success(res){
          if(res.data.code==200){
            _that.setData({
              data:res.data.data,
              showError:false,
              show:false
            })
          }else{
            _that.setData({
              data:'',
              showError:true,
              show:false
            })
          }
         
        }
      })
    }
    if(index==2){
      wx.request({
        url: 'http://localhost/Wx/HtNowList',
        success(res){
          _that.setData({
            data:res.data.data,
            show:false

          })
        }
      })
    }
  
    
   },

   onActive(event){
    this.setData({
      activeNames: event.detail,
    });
   },
   ChangeStatus(event){
     console.log(event)
    this.setData({
      showStatus:true,
      id:event.currentTarget.dataset.index
    })
   },
   onCancelStatus(event){

     this.setData({showStatus:false})
   },
   onConfirmStatus(event){
    var _that=this
    const { picker, value, index } = event.detail;
    console.log(event)
    console.log("value:"+value+",index:"+index)
    if(index==1){
      console.log("id:"+this.data.id)
      wx.request({
        url: 'http://localhost/Wx/updateHt',
        method:'post',
        header:{             
                 "Content-Type": "application/x-www-form-urlencoded"
        },
        data:{
          id:this.data.id,
          Status:1
        },
        success(res){
          console.log(res.data)
          if(res.data.code==200){
            console.log(res.data.code)
            setTimeout(function(){
              wx.showToast({
                title: '处理成功',
                duration:2000,
                mask:true,
                icon:'success',
                success:function(){ 
                  wx.navigateTo({
                    url: './dkAbnormalList',
                  })
                }
              }),3000
            })
          }else{

          }
        },
      })
    }
   }
})